import { NavBar } from 'antd-mobile';
import axios from 'axios';
import React, { useEffect, useState } from 'react'
import { useParams, useSearchParams } from 'react-router-dom'

function Index() {
  const [sp]=useSearchParams()
  console.log(sp);
  const start=sp.get('start')
  const end=sp.get('end')
  const [list,setList]=useState([])
  const getdata=async()=>{
    const res=await axios.get('/api/trip/airplane',{params:{start,end}})
    console.log(res)
    setList(res.data.data)
  }
  useEffect(()=>{
    getdata()
  },[])
  return (
    <div>
      <NavBar>{start}→{end}</NavBar>
      <div>
        {
          list?.map((v,i)=>{
            return <div key={i}  className="flight">
              <span>{v.dasn}</span>
              <span>{v.aasn}</span>
              <span>{v.aat}</span>
              <span>{v.ast}</span>
              <span>{v.dat}</span>
              <span>{v.dst}</span>
              <span>{v.sc}</span>
              <span>{v.sd}</span>
            </div>
          })
        }
      </div>
    </div>
  )
}

export default Index